# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Jaroslav Lichtblau <svetlemodry@archlinux.org>
# Contributor: Sébastien Luttringer

pkgname=ldoc
pkgver=1.5.0
pkgrel=1
_rockrel=1
pkgdesc='LuaDoc-compatible documentation generation system'
url="https://github.com/lunarmodules/$pkgname"
arch=(any)
license=(MIT)
depends=(lua
         # lua-markdown # claimed in rockspec but vendored?
         lua-penlight)
makedepends=(luarocks)
optdepends=('lua-discount: More full-featured Markdown support'
            'lua-lunamark: Alternative Markdown parser'
            'lua-cmark: CommonMark support')
_archive="$pkgname-$pkgver"
_rock="$_archive-$_rockrel.all.rock"
_rockspec="$_archive-$_rockrel.rockspec"
source=("$url/archive/v$pkgver/$_archive.tar.gz")
sha256sums=('4469cd74c8c7f51d3b9ce802d2239ba2b09d3d3a11273c3a5abdf273a0a53531')

build() {
	cd "$_archive"
	luarocks make --pack-binary-rock --deps-mode none -- rockspecs/$_rockspec
}

package() {
	cd "$_archive"
	luarocks --tree "$pkgdir/usr" \
		install --deps-mode none --no-manifest -- $_rock
	sed -i -e "s!$pkgdir!!" "$pkgdir/usr/bin/$pkgname"
	install -Dm0644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md manual.md
	install -Dm0644 -t "$pkgdir/usr/share/licenses/$pkgname/" COPYRIGHT
}
